import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import moment from 'moment';

export const columns: BasicColumn[] = [
  {
    title: '排序',
    dataIndex: 'sort',
  },
  {
    title: '岗位名称',
    dataIndex: 'name',
  },
  {
    title: '岗位标识',
    dataIndex: 'code',
  },
  {
    title: '备注',
    dataIndex: 'remark',
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    customRender: ({ record }) => {
      const time = record.createTime;
      return time ? moment(time).format('YYYY-MM-DD') : '-';
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '岗位名称',
    component: 'Input',
    colProps: { span: 8 },
    componentProps: ({ tableAction }) => {
      return {
        onPressEnter: () => {
          const { reload } = tableAction;
          reload();
        },
      };
    },
  },
  {
    field: 'code',
    label: '岗位标识',
    component: 'Input',
    colProps: { span: 8 },
    componentProps: ({ tableAction }) => {
      return {
        onPressEnter: () => {
          const { reload } = tableAction;
          reload();
        },
      };
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'name',
    label: '岗位名称',
    component: 'Input',
    required: true,
    componentProps: {
      placeholder: '请输入岗位名称',
    },
  },
  {
    field: 'code',
    label: '岗位标识',
    component: 'Input',
    required: true,
    componentProps: {
      placeholder: '请输入岗位标识',
    },
  },
  {
    field: 'status',
    label: '状态',
    defaultValue: 0,
    component: 'Switch',
    colProps: { span: 8 },
    required: true,
    componentProps: {
      checkedValue: 0,
      unCheckedValue: 1,
    },
  },
  {
    field: 'sort',
    label: '排序',
    component: 'Input',
    required: true,
    defaultValue: '255',
    componentProps: {
      placeholder: '请输入岗位序号',
    },
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
    componentProps: {
      placeholder: '请输入备注',
    },
  },
];
